package de.stefanocke.roo.wicket.table;

import java.util.List;

import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.springframework.roo.classpath.itd.ItdTypeDetailsProvidingMetadataItem;

import de.stefanocke.roo.wicket.RooTable;
import de.stefanocke.roo.wicket.Stereotypes;
import de.stefanocke.roo.wicket.base.BeanPropertiesAwareMetadataProvider;
import de.stefanocke.roo.wicket.base.ModelClassAwareMetadataCreationParams;
import de.stefanocke.roo.wicket.model.BeanPropertyMetadata;
import de.stefanocke.roo.wicket.model.BeanPropertyMetadataWithDetails;

/**
 * Provides {@link TableMetadata}.
 * 
 */
@Component
@Service
public final class TableMetadataProvider extends
		BeanPropertiesAwareMetadataProvider<TableMetadata, TableAnnotationValues> {

	public TableMetadataProvider() {
		super(RooTable.class, TableMetadata.class, TableAnnotationValues.class);
	}

	@Override
	protected ItdTypeDetailsProvidingMetadataItem getMetadataInternal(
			ModelClassAwareMetadataCreationParams<TableAnnotationValues> cmcp) {
		List<BeanPropertyMetadata> propertyMetadata = getBeanPropertiesMetadata(cmcp);

		List<BeanPropertyMetadataWithDetails<TableCellComponentMetadata>> tcPropertyMetadata = createBeanPropertyMetadataWithDetails(
				cmcp.getMid(), propertyMetadata, TableCellComponentMetadata.class);
				 
		return new TableMetadata(cmcp, tcPropertyMetadata);
	}

	


	@Override
	protected String[] requiredStereotypes() {
		return new String[] {Stereotypes.TABLE, Stereotypes.COMPONENT_FACTORY, Stereotypes.IENTITYBINDINGS};
	}

}